﻿using System;
using System.IO;
using System.Net.Mime;

using SBPweb.MediaCenter.Common.Modularity;
using SBPweb.MediaCenter.Common.Resources;

namespace SBPweb.MediaCenter.Common.Communication
{
    public class OpenFileMessage : MessageBase
    {

        #region Private fields

        private ContentType pContentType;
        private FileInfo pFileInfo;

        #endregion

        #region Constructor logic
        /*
        public OpenFileMessage(IModule sender, string text, string filePath)
            : this(sender, text, new FileInfo(filePath), FileHandler.ReadMimeTypeFrom(new FileInfo(filePath), "text/plain"))
        {
        }
        */
        public OpenFileMessage(IModule sender, string text, string filePath, string contentType)
            : this(sender, text, new FileInfo(filePath), new ContentType(contentType))
        {
        }

        public OpenFileMessage(IModule sender, string text, FileInfo fileInfo, string contentType)
            : this(sender, text, fileInfo, new ContentType(contentType))
        {
        }
        /*
        public OpenFileMessage(IModule sender, string text, FileInfo fileInfo)
            : this(sender, text, fileInfo, FileHandler.ReadMimeTypeFrom(fileInfo, "text/plain"))
        {
        }
        */
        public OpenFileMessage(IModule sender, string text, string filePath, ContentType contentType)
            : this(sender, text, new FileInfo(filePath), contentType)
        {
        }

        public OpenFileMessage(IModule sender, string text, FileInfo fileInfo, ContentType contentType)
            : base(sender, text)
        {
            pFileInfo = fileInfo;
            pContentType = contentType;
        }

        #endregion

        #region Property accessors

        public ContentType MimeType
        {
            get
            {
                return pContentType;
            }
        }

        public FileInfo FileInfo
        {
            get
            {
                return pFileInfo;
            }
        }

        #endregion

    }
}
